package CRequest

import (
	"arabApi/app/api/requests"
	"github.com/gin-gonic/gin"
	"github.com/thedevsaddam/govalidator"
)

type Oid struct {
	Id string `json:"id" valid:"id" form:"id"`
}

func CheckID(data interface{}, c *gin.Context) string {
	// 自定义验证规则
	rules := govalidator.MapData{
		"id": []string{"required"},
	}
	// 自定义验证出错时的提示
	messages := govalidator.MapData{
		"id": []string{
			"required:缺少ID",
		},
	}

	errs := requests.Validate1(data, rules, messages)
	return requests.GetOneErr(errs)
}
